package com.anyonavinfo.cpaddemo;

import android.app.Activity;



import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;

<<<<<<< HEAD

import com.anyonavinfo.cpaddemo.data.hostinfo.source.service.E3HWServiceManager;
import com.anyonavinfo.cpaddemo.service.musicplayerservice.MusicPlayerServiceManager;
import com.anyonavinfo.cpaddemo.view.mainview.MainView;
import com.anyonavinfo.cpaddemo.view.musicplayerview.MusicPlayerView;
import com.anyonavinfo.cpaddemo.view.settingsview.SettingsView;

=======

import com.anyonavinfo.cpaddemo.data.hostinfo.source.service.E3HWServiceManager;
import com.anyonavinfo.cpaddemo.service.musicplayerservice.MusicServiceManager;
import com.anyonavinfo.cpaddemo.view.mainview.MainView;
import com.anyonavinfo.cpaddemo.view.settingsview.SettingsView;
>>>>>>> b56716b621890f59100a220d4c7abe0ddb29e232

public class MainActivity extends Activity{

    private MainView lvMainView;
    private SettingsView lvSettingsView;
    private E3HWServiceManager mE3HWServiceManager;
    private MusicPlayerServiceManager mMusicServiceManager;
    private MusicPlayerView rlMusicPlayerView;

<<<<<<< HEAD
=======
public class MainActivity extends Activity{

    private MainView lvMainView;
    private SettingsView lvSettingsView;
    private E3HWServiceManager mE3HWServiceManager;
    private MusicServiceManager mMusicServiceManager;
>>>>>>> b56716b621890f59100a220d4c7abe0ddb29e232


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_mainactivity);
        lvMainView = (MainView) findViewById(R.id.lv_mianview);
        lvSettingsView = (SettingsView) findViewById(R.id.lv_settingsview);
<<<<<<< HEAD
        rlMusicPlayerView = (MusicPlayerView) findViewById(R.id.rl_musicplayerview);
        mE3HWServiceManager = E3HWServiceManager.getInstance();
        mMusicServiceManager = MusicPlayerServiceManager.getInstance();
=======
        mE3HWServiceManager = E3HWServiceManager.getInstance();
        mMusicServiceManager = MusicServiceManager.getInstance();
>>>>>>> b56716b621890f59100a220d4c7abe0ddb29e232
    }

    @Override
    protected void onResume() {
        super.onResume();
        ((Application)getApplication()).setStartActivityName(getClass().getName());
        boolean reloadAppInfo = ((Application)getApplication()).isBackendReturn();
        lvMainView.onResume(reloadAppInfo);
    }

    @Override
    public void onBackPressed() {
<<<<<<< HEAD
        lvMainView.onBackPressed();
        if (rlMusicPlayerView.isShown()){
            rlMusicPlayerView.onBackPressed();
        }
=======
/*        if (lvMainView.onBackPressed()){
            super.onBackPressed();
        }else {

        }*/
        lvMainView.onBackPressed();
>>>>>>> b56716b621890f59100a220d4c7abe0ddb29e232
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mE3HWServiceManager.endService();
<<<<<<< HEAD
=======
        mMusicServiceManager.stop();
>>>>>>> b56716b621890f59100a220d4c7abe0ddb29e232
        mMusicServiceManager.endService();
    }

    public void displaySettingsView(){
        lvMainView.setVisibility(View.GONE);
        TranslateAnimation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
                -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
        mShowAction.setDuration(500);
        lvSettingsView.setAnimation(mShowAction);
        lvSettingsView.setVisibility(View.VISIBLE);

    }

    public void hideSettingView(){
        TranslateAnimation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
                0.0f, Animation.RELATIVE_TO_SELF, -1.0f);
        mShowAction.setDuration(500);
        lvSettingsView.setAnimation(mShowAction);
        lvSettingsView.setVisibility(View.GONE);
        lvMainView.setVisibility(View.VISIBLE);
    }

<<<<<<< HEAD
    public void showMusicPlayerView(){
        lvMainView.setVisibility(View.GONE);
        TranslateAnimation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
                -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
        mShowAction.setDuration(500);
        rlMusicPlayerView.setAnimation(mShowAction);
        rlMusicPlayerView.onRedisplay();
        rlMusicPlayerView.setVisibility(View.VISIBLE);
    }

    public void hideMusicPlayerView(){
        TranslateAnimation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
                0.0f, Animation.RELATIVE_TO_SELF, -1.0f);
        mShowAction.setDuration(500);
        rlMusicPlayerView.setAnimation(mShowAction);
        rlMusicPlayerView.setVisibility(View.GONE);
        lvMainView.onRedisplay();
        lvMainView.setVisibility(View.VISIBLE);
    }

=======
>>>>>>> b56716b621890f59100a220d4c7abe0ddb29e232
}
